<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script type="text/javascript">
        const timer = setTimeout(function() {
            console.log(1); // 3秒之后，再执行这段代码。
            clearTimeout(timer);
        }, 3000);
    </script>
</body>

</html>